#ifndef BUTTON_H
#define BUTTON_H

#include "MoveableObj.h"

class AnimationSprite;

enum BUTTON_EVENT
{
	BTE_TOUCH_UP,
	BTE_TOUCH_DOWN,
};

class Button:public MoveableObj
{
private:

	int id;

	AnimationSprite *aniSpriteTouchUp;
	int aniIDTouchUp;
	int spriteIndexTouchUp;

	AnimationSprite *aniSpriteTouchDown;
	int aniIDTouchDown;
	int spriteIndexTouchDown;

	AnimationSprite *aniSpriteBackground;
	int aniIDBackground;
	int spriteIndexBackground;

	bool isTouchDown;

public:

	Button(int x, int y, int width, int height);
	~Button();

	bool IsTouchDownBy(int x, int y);
	bool IsTouchUpBy(int x, int y);

	// call 3 function below to get full feature button
	void SetImageForTouchUp(AnimationSprite *aniSprite, int aniID, int spriteIndex);
	void SetImageForTouchDown(AnimationSprite *aniSprite, int aniID, int spriteIndex);
	void SetImageForBackground(AnimationSprite *aniSprite, int aniID, int spriteIndex);

	void TouchUp();				//call when check this button is touched up
	void TouchDown();			//call when check this button is touched down

	void Render();

	void SetID(int id);

	bool GetIsTouchDown(){return isTouchDown;}
	int GetID(){return id;}
};

#endif


/*
example about touch down event
Button* bPressed = 0;


if(IsPointInRect(x, y, bHint->GetRect()))
bPressed = bHint;
if(IsPointInRect(x, y, bOption->GetRect()))
bPressed = bOption;

if(bPressed != 0)
{
bPressed->TouchDown();
OnButtonClick(bPressed, BTE_TOUCH_DOWN);
}

example about touch up event

Button* bPressed = 0;

if(bStart->GetIsTouchDown() == true) bPressed = bStart;
if(bExit->GetIsTouchDown() == true) bPressed = bExit;

if(bPressed != 0)
{
bPressed->TouchUp();
OnButtonClick(bPressed, BTE_TOUCH_UP);
}

*/